import React, { useState, useEffect } from 'react'
import styles from '../css/News.module.css'
import { Arrow, Like } from '@react-vant/icons'
import { Card, Image } from 'react-vant'
import { TypeListQuery } from '../sevice/NewService'
import { useNavigate } from 'react-router-dom'
import { PullRefresh, List, Tabs, Cell } from 'react-vant'  //下拉刷新  下拉加载
export default function AllNew() {

    const navigate = useNavigate();
    let [newList, setnewList] = useState([])

    useEffect(() => {
        (async () => {
            let { data } = await TypeListQuery(
                {
                    type: '26'
                }
            )
            if (data.code == 200) {
                if (data.rows.length) {
                    setnewList(data.rows)
                }
            }
        })()
    }, [])


 

    const BtnId = (id) => {

       navigate(`/Lifepay/newDetail/${id}`)

    }



    return (
        <div>

            {newList.map(item => {

                return <div style={{
                    paddingTop: 10,
                    margin: 10,
                    borderBottom: ' 0.5px  solid grey '
                }} key={item.id}
                    onClick={() => {
                        BtnId(item.id)
                    }}>

                    <Card >
                        <Card.Cover>
                            <Image lazyload src={"/api" + item.cover}
                                style={{ height: 100, width: '100%' }} />
                        </Card.Cover>
                        <Card.Header extra={<Arrow />}>
                            {item.title}
                        </Card.Header>
                        <Card.Body className={styles.a}>
                            {item.content}
                        </Card.Body>
                        <div style={{ marginLeft: 200, marginTop: 10, paddingBottom: 10, }}>2022-12-14 15:33:57</div>
                    </Card>
                </div>

            })}

        </div>
    )
}
